package com.xvheng.module.backendApi.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xvheng.common.annotation.Log;
import com.xvheng.common.core.controller.BaseController;
import com.xvheng.common.core.domain.AjaxResult;
import com.xvheng.common.enums.BusinessType;
import com.xvheng.module.backendApi.domain.ConfirmLog;
import com.xvheng.module.backendApi.service.IConfirmLogService;
import com.xvheng.common.utils.poi.ExcelUtil;
import com.xvheng.common.core.page.TableDataInfo;

/**
 * 核销记录Controller
 * 
 * @author xvheng
 * @date 2025-01-03
 */
@RestController
@RequestMapping("/backendApi/log")
public class BackendConfirmLogController extends BaseController
{
    @Autowired
    private IConfirmLogService confirmLogService;

    /**
     * 查询核销记录列表
     */
    @PreAuthorize("@ss.hasPermi('backendApi:log:list')")
    @GetMapping("/list")
    public TableDataInfo list(ConfirmLog confirmLog)
    {
        startPage();
        List<ConfirmLog> list = confirmLogService.selectConfirmLogList(confirmLog);
        return getDataTable(list);
    }

    /**
     * 导出核销记录列表
     */
    @PreAuthorize("@ss.hasPermi('backendApi:log:export')")
    @Log(title = "核销记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ConfirmLog confirmLog)
    {
        List<ConfirmLog> list = confirmLogService.selectConfirmLogList(confirmLog);
        ExcelUtil<ConfirmLog> util = new ExcelUtil<ConfirmLog>(ConfirmLog.class);
        util.exportExcel(response, list, "核销记录数据");
    }

    /**
     * 获取核销记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('backendApi:log:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(confirmLogService.selectConfirmLogById(id));
    }

    /**
     * 新增核销记录
     */
    @PreAuthorize("@ss.hasPermi('backendApi:log:add')")
    @Log(title = "核销记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ConfirmLog confirmLog)
    {
        return toAjax(confirmLogService.insertConfirmLog(confirmLog));
    }

    /**
     * 修改核销记录
     */
    @PreAuthorize("@ss.hasPermi('backendApi:log:edit')")
    @Log(title = "核销记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ConfirmLog confirmLog)
    {
        return toAjax(confirmLogService.updateConfirmLog(confirmLog));
    }

    /**
     * 删除核销记录
     */
    @PreAuthorize("@ss.hasPermi('backendApi:log:remove')")
    @Log(title = "核销记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(confirmLogService.deleteConfirmLogByIds(ids));
    }
}
